#include "correlationfilter.h"

CorrelationFilter::CorrelationFilter(void)
{
	mode = Between;
	corrAbove = 0;
	corrBelow = 1;
}

CorrelationFilter::~CorrelationFilter(void)
{
}

bool CorrelationFilter::accepts(AnatomicalLink* link)
{
	switch(mode)
	{
		case Above:
			return (link->correlation() >= corrAbove);
		case Below:
			return (link->correlation() <= corrBelow);
		case Between:
			return ((link->correlation() >= corrAbove) &&
				(link->correlation() <= corrBelow));
		default:
			return true;
	}
}

void CorrelationFilter::setFilterToAcceptAbove(double corr)
{
	mode = Above;
	corrAbove = corr;
	emit filterChanged(this);
}

void CorrelationFilter::setFilterToAcceptBelow(double corr)
{
	mode = Below;
	corrBelow = corr;
	emit filterChanged(this);
}

void CorrelationFilter::setFilterToAcceptBetween(double corr1, double corr2)
{
	mode = Between;
	corrAbove = corr1;
	corrBelow = corr2;
	emit filterChanged(this);
}
